package com.siwei.mes.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * 试验项目类型枚举类
 *
 * @Description: 试验项目类型枚举类  字典表（TEST_PROJECT）
 * @Version: 1.0
 * @author: mlchen
 * @date: 2024/5/23 14:34
 */
@Getter
public enum TestProjectTypeEnum {
    CEMENT("CEMENT", "水泥"),
    COARSE_AGGREGATE("COARSE_AGGREGATE", "粗骨料"),
    FINE_AGGREGATE("FINE_AGGREGATE", "细骨料"),
    FLY_ASK("FLY_ASK", "粉煤灰"),
    SLAG("SLAG", "矿渣粉"),
    CONCRETE("CONCRETE", "混凝土"),
    CONCRETE_ADMIXTURE("CONCRETE_ADMIXTURE", "混凝土外加剂"),
    MORTAR("MORTAR", "砂浆"),
    MORTAR_ADMIXTURE("CEMENT", "砂浆外加剂"),
    ;

    private String code;

    private String name;

    TestProjectTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据code查找name
     *
     * @param code
     * @return
     */
    public static String selectByCodeName(String code) {
        TestProjectTypeEnum typeEnum = Arrays.stream(values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        if (typeEnum == null) {
            return null;
        }
        return typeEnum.getName();
    }
}
